<template>
  <div>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns1"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange"
    >
      <template v-slot:complateAdvice="text">
        <j-ellipsis :value="text" :length="10" />
      </template>
      <span slot="action" slot-scope="text, record">
        <!-- <a-icon type="vertical-align-bottom" @click="handleDownloadFile(record.url)"></a-icon> -->
        <a @click="handleToDetail(record)">查看</a>
      </span>
    </a-table>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { columns1 } from './indexColumns'
export default {
  mixins: [JeecgListMixin],
  data() {
    return {
      columns1: columns1(this),
      dataSource: [],
      url: {
        list: '/sjdb/sjDaiban/queryDbList',
      },
      shouldShowAction(record) {
        // 根据某个条件决定是否显示操作列
        return record.showAction; // 例如根据 record 的 showAction 属性来判断
      }
      //   disableMixinCreated: true,
    }
  },
  created() {
    this.queryParam.state = 2
  },
  mounted() {
    // 在 mounted 生命周期中移除操作列
    this.removeActionColumn();
  },
  methods: {
    removeActionColumn() {
      // 通过条件或直接移除操作列
      this.columns1 = this.columns1.filter(col => col.key !== 'action');
    },
    handleDownloadFile(fileUrl) {
      this.$message.success('正在下载，请稍等！')
      let url = `${window._CONFIG['domianURL']}/sys/common/download/${fileUrl}`
      window.open(url, '_blank')
    },
    handleToDetail(record) {
      console.log(record, 'record')
      // const regex = /\[(.+?)\]/g //获取中括号内容
      // const key = regex.exec(record.title)[1]
      // const routerName = record.stagename.split('-')[0] || ''
      if (record.href) {
        this.$router.push(record.href)
        this.$emit('closed')
      } else {
        this.$message.error('未找到该路径！')
      }
    },
  },
}
</script>

<style>
</style>